package Work0529;

import java.util.*;

public class Company {
	private String name;// 姓名
	private String address;// 地址
	private long phone;// 电话
	private String range;// 范围
	List<Staff> list = new ArrayList<Staff>();

	public Company(String name, String address, long phone, String range) {
		super();
		this.name = name;
		this.address = address;
		this.phone = phone;
		this.range = range;
	}

	/**
	 * 展示信息
	 */
	public void show() {
		System.out.println(name + "公司,地址" + address + ",电话" + phone + ",经营范围" + range + ",欢迎您的加入.");
	}

	/***
	 * 招聘员工
	 * 
	 * @param name
	 * @param old
	 * @param sex
	 * @param post
	 * @param salary
	 * @return
	 */
	public boolean addStaff(String name, int old, String sex, String post, int salary, int jobNo) {
		if (cheakStaff(jobNo)) {
			list.add(new Staff(name, old, sex, post, salary, jobNo));
			return true;
		}
		return false;
	}

	/**
	 * 检查工号
	 * 
	 * @param jobNo
	 * @return
	 */
	public boolean cheakStaff(int jobNo) {
		for (int a = 0; a < list.size(); a++) {
			if (list.get(a).getJobNo() == jobNo) {
				return false;
			}
		}
		return true;
	}

	/**
	 * 展示员工信息
	 */
	public void showStaff() {
		System.out.println("姓名\t年龄\t性别\t职位\t薪水  \t工号");
		for (int a = 0; a < list.size(); a++) {
			list.get(a).show();
		}
	}

	/**
	 * 辞退员工
	 * 
	 * @param name
	 * @return
	 */
	public boolean dismissal(int jobNo) {
		for (int a = 0; a < list.size(); a++) {
			if (list.get(a).getJobNo() == jobNo) {
				list.remove(a);
				return true;
			}
		}
		return false;
	}

	/**
	 * 计算总数量
	 * 
	 * @return
	 */
	public int statistics() {
		return list.size();

	}

	public void findMaxAge() {
		Staff max = Collections.max(list);
		System.out.print("该员工名为" + max.getName() + ",原本工资为" + max.getSalary() + ",");
		max.setSalary(max.getSalary() + 1000);
		System.out.println("现在工资为" + max.getSalary());

	}
}
